<template>
  <div>
    <el-form ref="form" :model="form" :rules="rules" label-width="80px">
                      <el-form-item label="用户名" prop="username">
                        <el-input v-model="form.username" placeholder="请输入用户名" />
                      </el-form-item>
                      <el-form-item label="生日" prop="birthday">
                        <el-date-picker clearable
                                        v-model="form.birthday"
                                        type="date"
                                        value-format="yyyy-MM-dd"
                                        placeholder="请选择生日">
                        </el-date-picker>
                      </el-form-item>
                      <el-form-item label="地址" prop="address">
                        <el-input v-model="form.address" placeholder="请输入地址" />
                      </el-form-item>
    </el-form>
    <div slot="footer" class="dialog-footer">
      <el-button type="primary" @click="submitForm">确 定</el-button>
      <el-button @click="cancel">取 消</el-button>
    </div>
  </div>
</template>

<script>
import AddMixin from "@/minixs/basic/add"
import request from "@/utils/request";
export default {
  name: "add",
  mixins:[AddMixin],
  data() {
    return {
      // 表单数据
      form: {
                      id: null,
                      username: null,
                      birthday: null,
                      sex: null,
                      address: null
      },
      // 表单校验
      rules: {
                      username: [
                  { required: true, message: "用户名不能为空", trigger: "blur" }
                ],
      }
    }
  },
  methods: {
    // 保存数据
    save(){
      request({
        url: '/demo/user',
        method: 'post',
        data: this.form
      }).then(response => {
        this.$modal.msgSuccess("新增成功");
        this.$emit("reload")
        this.cancel();
      });
    },
  }
};
</script>
